/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package frontera;


import Entidad.Compra;
import Entidad.Sistema;
import Entidad.Tarea;
import java.util.ArrayList;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.JTable;
/**
 *
 * @author Stiv
 */
public class Tareas extends javax.swing.JPanel {
    
    DefaultTableModel dtmtareas;
    
    public Tareas() {
        initComponents();
        inicializar();
    }
    
    
    public void inicializar(){
        NuevaTareaBT.setVisible(true);
        dtmtareas = new DefaultTableModel(new Object[][] {
		}, new String[] { "Estado","Cliente", "ID","Fecha", "Tipo", "Asignada"}){};
        TablaTareas.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); 
        
        

        
       Tarea tarea1 = new Tarea("Preparado",25,"2012,09,18", "2012,09,18","Envio","envio de mercancia al cliente en las horas de la mañana",
               new Compra() );
       Sistema.mTarea.add(tarea1);
       TablaTareas.setModel(dtmtareas);        
        
       for(Tarea p: Sistema.getTarea()){
           
           dtmtareas.addRow(new Object[]{p.getEstado(), "alejandro Fabbri", p.getID(),p.getFecha_fin(),
           p.getTipo(), "Andres EScobar"});
           AsuntoTF.setText(p.getDescripcion());
       
               }
       
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        pestañas = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        TablaTareas = new javax.swing.JTable();
        AsuntoTF = new javax.swing.JTextField();
        NuevaTareaBT = new javax.swing.JButton();

        jScrollPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("Tareas"));

        TablaTareas.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {"Preparado", null,  new Double(34562.0), "18/09/12", "envio", "Despacho"},
                {null, null, null, null, null, null},
                {null, null, null, null, null, null}
            },
            new String [] {
                "Estado", "Cliente", "ID", "Fecha", "Tipo", "Asignada"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.Object.class, java.lang.Double.class, java.lang.Object.class, java.lang.String.class, java.lang.Object.class
            };
            boolean[] canEdit = new boolean [] {
                false, true, false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane1.setViewportView(TablaTareas);

        NuevaTareaBT.setText("Nueva Tarea");
        NuevaTareaBT.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NuevaTareaBTActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(AsuntoTF, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 887, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(NuevaTareaBT)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(87, 87, 87)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(AsuntoTF, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(NuevaTareaBT)
                .addContainerGap(69, Short.MAX_VALUE))
        );

        pestañas.addTab("Tareas", jPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pestañas)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pestañas)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void NuevaTareaBTActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NuevaTareaBTActionPerformed
        NuevaTarea nueva = new NuevaTarea();
        nueva.setVisible(true);
    }//GEN-LAST:event_NuevaTareaBTActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField AsuntoTF;
    private javax.swing.JButton NuevaTareaBT;
    private javax.swing.JTable TablaTareas;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane pestañas;
    // End of variables declaration//GEN-END:variables
}
